package com.example.memorypoint.entity;

import android.os.Parcel;
import android.os.Parcelable;

public class Diary implements Parcelable {

    private int id;
    private String date;
    private String title;
    private String content;
    private int weather;
    private int emoji;
    private String time;

    // 构造方法
    public Diary(String date, int weather, int emoji, String time) {
        this.date = date;
        this.weather = weather;
        this.emoji = emoji;
        this.time = time;
    }

    public Diary(int id, String date, String title, String content, int weather, int emoji, String time) {
        this.id = id;
        this.date = date;
        this.title = title;
        this.content = content;
        this.weather = weather;
        this.emoji = emoji;
        this.time = time;
    }

    public Diary(int id, String date, String title, String content, int weather, int emoji) {
        this.id = id;
        this.date = date;
        this.title = title;
        this.content = content;
        this.weather = weather;
        this.emoji = emoji;
    }

    public Diary(String date) {
        this.date = date;
    }

    public Diary(String date, int weather, int emoji) {
        this.date = date;
        this.weather = weather;
        this.emoji = emoji;
    }

    public Diary(String date, String title, String content) {
        this.date = date;
        this.title = title;
        this.content = content;
    }

    public Diary(int id, String date, String title, String content) {
        this.id = id;
        this.date = date;
        this.title = title;
        this.content = content;
    }

    // Getter 和 Setter 方法
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getWeather() {
        return weather;
    }

    public void setWeather(int weather) {
        this.weather = weather;
    }

    public int getEmoji() {
        return emoji;
    }

    public void setEmoji(int emoji) {
        this.emoji = emoji;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    // 实现 Parcelable 接口

    // 从 Parcel 中读取数据
    protected Diary(Parcel in) {
        id = in.readInt();
        date = in.readString();
        title = in.readString();
        content = in.readString();
        weather = in.readInt();
        emoji = in.readInt();
        time = in.readString();
    }

    // 写入数据到 Parcel
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeString(date);
        dest.writeString(title);
        dest.writeString(content);
        dest.writeInt(weather);
        dest.writeInt(emoji);
        dest.writeString(time);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    // 创建一个 CREATOR 用于反序列化
    public static final Creator<Diary> CREATOR = new Creator<Diary>() {
        @Override
        public Diary createFromParcel(Parcel in) {
            return new Diary(in);
        }

        @Override
        public Diary[] newArray(int size) {
            return new Diary[size];
        }
    };
}
